package com.mall.hadoop.job.sdkclick;
import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import com.mall.manager.service.SdkClickService;
/**
 * @按钮点击统计表
 * @author liugb
 * @date 2016 7 12
 */
public class SdkClickReduce extends Reducer<Text, IntWritable, Text, IntWritable>{

	@Override
	protected void reduce(Text key, Iterable<IntWritable> v2s,Context context) throws IOException, InterruptedException {
		// TODO Auto-generated method stub
		int sum = 0;
		// 迭代他的次数
		for (IntWritable lw : v2s) {
			// 求和
			sum += lw.get();
		}
		// 处理数据保存到mysql中
		SdkClickService.manager_insert_sdkclick(key.toString(),sum);
		// 输出
		context.write(key, new IntWritable(sum));
	}

}
